#ifndef __STDMYSTRING_H_
#define __STDMYSTRING_H_

#include <iostream>

class MyStringList; //前置声明

class StdMyString
{
public:
    StdMyString();//无参构造

    StdMyString(const char* str);//带参构造

    StdMyString(const StdMyString& str);    //拷贝构造函数

    ~StdMyString();

    StdMyString& operator=(const StdMyString& str);//传引用可以减少拷贝

    StdMyString& operator+=(const StdMyString& str);

    StdMyString& operator+=(const char& c);

    StdMyString operator+(const StdMyString &str);

    StdMyString& operator-=(const StdMyString& str);

    StdMyString operator-(const StdMyString &str);

    char& operator[](int index);
    //逻辑运算符重载
    bool operator==(const StdMyString & str);
    bool operator>(const StdMyString & str);
    bool operator<(const StdMyString & str);
    //bool operator&&(const StdMyString & str); //不能重载？原因？

    friend std::ostream& operator<<(std::ostream &os, const StdMyString &str);
    friend std::istream& operator>>(std::istream &os, StdMyString &str);

    operator int();
    operator double();

    MyStringList split(const StdMyString& str);

private:
    char *string;
    int size;
    int capacity;

};

std::ostream& operator<<(std::ostream &os, const StdMyString &str);
std::istream& operator>>(std::istream &is, const StdMyString &str);

class MyStringList
{
public:
    MyStringList(int capacity = 15);
    //拷贝构造 赋值运算符重载
    // - -= == > < [] >>
    
    MyStringList& operator+=(const StdMyString& str);

    MyStringList& operator<<(const StdMyString &str);

    MyStringList operator+(const MyStringList &list);

    friend std::ostream& operator<<(std::ostream& os, const MyStringList& list);
~MyStringList();
private:
    StdMyString *array;
    int size;
    int capacity;
};

std::ostream& operator<<(std::ostream& os, const MyStringList& list);

#endif